﻿using System.Reflection;

namespace smp.QueryDb.Executing
{
    public interface IExecuteReadTo<TViewModel>
    {
        ExecuteRead<TViewModel> To(string outputField);
    }

    internal class ExecuteReadTo<TViewModel> : IExecuteReadTo<TViewModel>
    {
        private readonly ExecuteRead<TViewModel> _execute;
        private readonly PropertyInfo _property;

        internal ExecuteReadTo(ExecuteRead<TViewModel> execute, PropertyInfo property)
        {
            _execute = execute;
            _property = property;
        }

        #region Implementation of IExecuteReadTo<TViewModel>

        public ExecuteRead<TViewModel> To(string outputField)
        {
            _execute.AddProperty(outputField, _property);
            return _execute;
        }

        #endregion
    }
}
